package model.manytomany;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQuery;
import javax.persistence.Table;


/**
 * The persistent class for the teacher database table.
 * 
 */
@Entity
@Table(name="teacher")
@NamedQuery(name = "Teacher.getLastTeacher", query = "select max(t.tId) from Teacher t")
public class Teacher implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="t_id", unique=true, nullable=false)
	private int tId;

	@Column(name="t_name", nullable=false, length=45)
	private String tName;

	//bi-directional many-to-many association to Student
	@ManyToMany(mappedBy="teachers")
	private List<Student> students=new ArrayList<Student>();

	public Teacher() {
	}

	public int getTId() {
		return this.tId;
	}

	public void setTId(int tId) {
		this.tId = tId;
	}

	public String getTName() {
		return this.tName;
	}

	public void setTName(String tName) {
		this.tName = tName;
	}

	public List<Student> getStudents() {
		return this.students;
	}

	public void setStudents(List<Student> students) {
		this.students = students;
	}
	
	
	
	
	
	

	public void addStudent(Student s) {
		getStudents().add(s);
	}

	public void removeStudent(Student s) {
		if (getStudents().contains(s)) {
			getStudents().remove(s);
		}
	}

}